using MauiApp.ViewModels;
using System;
using Microsoft.Maui.Controls;

namespace MauiApp.Views
{
    public partial class StudyStatsPage : ContentPage
    {
        private StudyStatsViewModel viewModel;

        public StudyStatsPage()
        {
            InitializeComponent();
            viewModel = BindingContext as StudyStatsViewModel;
        }

        protected override async void OnAppearing()
        {
            base.OnAppearing();
            if (viewModel != null)
            {
                await viewModel.InitializeAsync();
            }
        }

        private async void DatePicker_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (viewModel != null && e.PropertyName == "Date")
            {
                viewModel.RefreshAllAnalysesCommand.Execute(null);
            }
        }
    }
}